<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                                 xmlns:h="http://java.sun.com/jsf/html"
                                 xmlns:f="http://java.sun.com/jsf/core"
                                 xmlns:ui="http://java.sun.com/jsf/facelets"
                                 xmlns:p="http://primefaces.org/ui"
                                 template="/templates/ui.xhtml">

    <ui:define name="head">
        <script type="text/javascript" src="#{request.contextPath}/UI/support/pub.js"/>
        <script type="text/javascript" language="javascript">
            document.onkeydown = function TabReplace() {
                if (event.keyCode == 13) {
                    if (event.srcElement.tagName != 'BUTTON')
                        event.keyCode = 9;
                    else
                        event.srcElement.click();
                }
            }
            function actSelect(obj,pageName) {
                var pkid=obj;
                var sfeature = "dialogwidth:1300px; dialogheight:700px;center:yes;location:no;help:no;resizable:no;scroll:yes;status:no";
                var arg = new Object();
                arg.doType = "select";
                if (pageName=="Tk_Detail"){
                    var rtn =dialog("../item/itemHieRelapMng.xhtml?strType=0&amp;strTkCttPkid="+pkid+"",arg,sfeature);
                }
                else if (pageName=="Tk_Cstpl_Detail"){
                    var rtn =dialog("../contract/initCstplMng.xhtml?strTkCttPkid="+pkid+"",arg,sfeature);
                }
            }
        </script>

	<style type="text/css">
        .img {
            width: 20px;
            height: 30px;
        }
    </style>

    </ui:define>
    <ui:define name="content">
        <div style="margin:5px;">
            <h:form id="form">
                <p:growl id="msgs" showDetail="true"/>
                <p:focus for="id"/>
                <p:panel id="ppCondition" header="客户信息录入" style="width: 100%">
                    <h:panelGrid>
                        <h:selectOneRadio id="radio" value="#{esPowerAction.strOperType}">
                            <f:selectItem itemLabel="查询" itemValue="strRadioQry" />
                            <f:selectItem itemLabel="编辑" itemValue="strRadioEdit" />
                            <p:ajax update="pgCondition,pdt" listener="#{esInitCustAction.radioOnClickForPowerAction('Mng')}" />
                        </h:selectOneRadio>
                    </h:panelGrid>
                    <h:panelGrid id="pgCondition" columns="2" style="width: 100%">
                        <h:panelGrid id="pgCust" columns="8">
                            <h:outputLabel value="客户编号：" for="id" style="font-weight: bold"/>
                            <p:inputText id="id" value="#{esInitCustAction.esInitCust.id}"
                                    disabled="#{esInitCustAction .strIdDisabled}"
                                    style="#{esInitCustAction .strIdDisabledStyle};width:127px"/>

                            <h:outputLabel value="客户名称：" for="name" style="font-weight: bold"/>
                            <p:inputText id="name" value="#{esInitCustAction.esInitCust.name}"
                                         disabled="#{esInitCustAction .strDisabled}"
                                         style="#{esInitCustAction .strDisabledStyle};width:127px"/>

                            <h:outputLabel value="手机：" for="mobilephone" style="font-weight: bold"/>
                            <p:inputText id="mobilephone" value="#{esInitCustAction.esInitCust.mobilephone}"
                                         disabled="#{esInitCustAction .strDisabled}"
                                         style="#{esInitCustAction .strDisabledStyle};width:127px"/>

                            <h:outputLabel value="电话：" for="operphone" style="font-weight: bold"/>
                            <p:inputText id="operphone" value="#{esInitCustAction.esInitCust.operphone}"
                                         disabled="#{esInitCustAction .strDisabled}"
                                         style="#{esInitCustAction .strDisabledStyle};width:127px"/>

                            <h:outputLabel value="其他电话：" for="otherphone" style="font-weight: bold"/>
                            <p:inputText id="otherphone" value="#{esInitCustAction.esInitCust.otherphone}"
                                         disabled="#{esInitCustAction .strDisabled}"
                                         style="#{esInitCustAction .strDisabledStyle};width:127px"/>

                            <h:outputLabel value="传真：  " for="fax" style="font-weight: bold"/>
                            <p:inputText id="fax" value="#{esInitCustAction.esInitCust.fax}"
                                         disabled="#{esInitCustAction .strDisabled}"
                                         style="#{esInitCustAction .strDisabledStyle};width:127px"/>

                            <h:outputLabel value="邮箱：" for="email" style="font-weight: bold"/>
                            <p:inputText id="email" value="#{esInitCustAction.esInitCust.email}"
                                         disabled="#{esInitCustAction .strDisabled}"
                                         style="#{esInitCustAction .strDisabledStyle};width:127px"/>

                            <h:outputLabel value="备注内容：" for="note" style="font-weight: bold"/>
                            <p:inputTextarea id="note" value="#{esInitCustAction.esInitCust.note}"
                                              rows="1" autoResize="false"
                                              disabled="#{esInitCustAction .strDisabled}"
                                              style="#{esInitCustAction .strDisabledStyle};width:127px"/>
                        </h:panelGrid>
                        <h:panelGrid columns="1" >
                            <p:commandButton id="qryBtn" value="查询"
                                             action="#{esInitCustAction.onQueryAction}"
                                             update="pdt,msgs"
                                             rendered="#{esPowerAction.strBtnQryRendered}">
                            </p:commandButton>
                            <p:commandButton id="submitBtn"
                                             value="#{esInitCustAction.strSubmitBtnName}"
                                             action="#{esInitCustAction.submitThisRecordAction}"
                                             update="pdt,msgs"
                                             rendered="#{esPowerAction.strBtnEditRendered}">
                            </p:commandButton>
                            <p:commandButton id="resetBtn" value="重置"
                                             action="#{esInitCustAction.resetAction}"
                                             update="pgCondition,msgs">
                            </p:commandButton>
                        </h:panelGrid>
                    </h:panelGrid>
                </p:panel>

                <p:ajaxStatus style="width:16px;height:16px;">
                    <f:facet name="start">
                        <h:graphicImage value="/images/ajaxloading.gif"/>
                    </f:facet>
                    <f:facet name="complete">
                        <h:outputText value=""/>
                    </f:facet>
                </p:ajaxStatus>

                <!--列表维护-->
                <p:contextMenu for="pdt">
                    <p:menuitem value="增加" icon="ui-icon-plus"
                                actionListener="#{esInitCustAction.selectRecordAction('Mng','Add')}" update="pdt,msgs,ppCondition">
                    </p:menuitem>
                    <p:menuitem value="更新" icon="ui-icon-arrowrefresh-1-w"
                                actionListener="#{esInitCustAction.selectRecordAction('Mng','Upd')}" update="pdt,msgs,ppCondition">
                    </p:menuitem>
                    <p:menuitem value="删除" icon="ui-icon-close"
                                actionListener="#{esInitCustAction.selectRecordAction('Mng','Del')}" update="pdt,msgs,ppCondition">
                    </p:menuitem>
                </p:contextMenu>
                <p:dataTable id="pdt" style="width:100%;"
                             value="#{esInitCustAction.listInitCust}"
                             var="record"
                             rowKey="#{record.pkid}"
                             selection="#{esInitCustAction.esInitCustSelected}"
                             selectionMode="single"
                             paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                             paginator="true"
                             paginatorPosition="bottom"
                             rows="20"
                             rowsPerPageTemplate="200,100,50,40,30,20,10"
                             emptyMessage="数据记录为空..."
                             widgetVar="DtInitCustList"
                             scrollable="true"
                             scrollHeight="400">

                    <!--<p:ajax event="rowSelect" listener="#{esInitCustAction.onRowSelect}" update=":form"/>-->

                    <p:column headerText="pkid" style="display:none;" rendered="false">
                        <h:outputText id="tetid" style="display:none;" rendered="false" value="#{record.pkid}"/>
                    </p:column>

                    <p:column headerText="客户编号" style="width:200px;text-align:center">
                        <h:outputText value="#{record.id}"/>
                    </p:column>

                    <p:column headerText="客户名称" style="width:360px;text-align:left">
                        <h:outputText value="#{record.name}"/>
                    </p:column>

                    <p:column headerText="手机" style="text-align:center">
                        <h:outputText value="#{record.mobilephone}"/>
                    </p:column>

                    <p:column headerText="邮箱" style="text-align:center">
                        <h:outputText value="#{record.email}"/>
                    </p:column>

                    <p:column headerText="电话" style="text-align:center">
                        <h:outputText value="#{record.operphone}"/>
                    </p:column>

                    <p:column headerText="其他电话" style="text-align:center">
                        <h:outputText value="#{record.otherphone}"/>
                    </p:column>

                    <p:column headerText="传真" style="text-align:center">
                        <h:outputText value="#{record.fax}"/>
                    </p:column>

                    <p:column headerText="备注内容" style="text-align:center">
                        <h:outputText value="#{record.note}"/>
                    </p:column>
                </p:dataTable>
            </h:form>
        </div>
    </ui:define>

</ui:composition>